import userUtil from '../../../js/util/user'
export default {
    name: "login",
    data() {
        return {
            user:{
                userName:"",
                pwd:""
            },
        }
    },
    created : function() {
        /*登录页面去掉token*/
        this.set("user_login_token","");
     /*  if(this.get("user_login_token")){
           this.getCarouselFn();
       }else{
           this.reload=true;
       }*/
    },
    mounted : function() {

    },
    methods: {
        loginFn:function () {
            const param= this.user;
            this.user.userName=$.trim(this.user.userName);
            this.user.pwd=$.trim(this.user.pwd);
            if(!this.user.userName){
                this.layer.alert("账号不能为空");
                return;
            }
            if(!this.user.pwd){
                this.layer.alert("密码不能为空");
                return;
            }
            this.$post(url.adminLogin, param)
                .then((response) => {
                    userUtil.setToken(response.data)
                    this.$router.push({path: '/ipad/securityMap'});
                }).catch(err => {
                console.log(err);
            })
        }
    }
}
